#include <stdio.h>
#include <stdlib.h>

/*乘式还原（1）*/
int jud(int q,char *pflag);
void print(int a,int b,int s1,int s2,int s3);



void main()
{
    long i,j,k,l,m,n,term,t1,t2,t3;
    int flag;
    for(i=0;i<=4;++i)
    for(j=5;j<=9;++j)
        for(k=0;k<=4;++k)
        {
            term= 100*i+10*j+k;
            for(flag=0,n=0;n<4&&!flag;)
            flag = jud((t3=++n*100*term)/100,"001");

            if(flag){
                for(flag=0,m=0;m<4&&!flag;)
                flag = jud((t2=++m*10*term)/10,"1100");

                if(flag){
                     for(flag=0,l=5;l<9&&!flag;)
                     flag = jud(t1= ++l*term,"0000");

                     if(flag&&jud(t1+t2+t3,"00101")){
                        printf(term,n*100+m*10+l,t1,t2,t3);
                     }

                }
                   
            }
        }

}

void print(int a,int b,int s1,int s2,int s3)
        {
            printf("\n    %ld\n",a);
            printf("*)%ld\n",b);
            printf("..............\n");
            printf("    %ld\n  %ld\n %ld\n",s1,s2/10,s3/100);
            printf("..............\n");
            printf("%ld\n",a*b);
        }

        int jud(int q,char *pflag)
        {
            while(q!=0&&*pflag!=NULL)
                if(*pflag-'0'!=(q%10>=5?1:0))
                return 0;
                else{q/=10; ++pflag;}
                if(q==0&&*pflag==NULL)
                return 1;
                else return 0;
        }